import { ApiUtils } from '../../api/utils/ApiUtils';
import { Byte } from '../../api/io/Byte';
import { Loader } from '../../api/io/Loader';
import { ITimer } from '../../api/timer/ITimer';
import { CDActivityGlobal } from './CDActivityGlobal';
import { CDActivity } from './CDActivity';
import { CDArenaGlobal } from './CDArenaGlobal';
import { CDArenaRule } from './CDArenaRule';
import { CDArenaRobot } from './CDArenaRobot';
import { CDAudio } from './CDAudio';
import { CDBuyTimes } from './CDBuyTimes';
import { CDBuyTimeLimit } from './CDBuyTimeLimit';
import { CDDropGroup } from './CDDropGroup';
import { CDDrop } from './CDDrop';
import { CDDropSet } from './CDDropSet';
import { CDDropChoose } from './CDDropChoose';
import { CDEquipmentGlobal } from './CDEquipmentGlobal';
import { CDEquipment } from './CDEquipment';
import { CDEquipmentRMath } from './CDEquipmentRMath';
import { CDEquipmentLevel } from './CDEquipmentLevel';
import { CDEquipmentColor } from './CDEquipmentColor';
import { CDEquipmentSuit } from './CDEquipmentSuit';
import { CDEquipmentChange } from './CDEquipmentChange';
import { CDEquipmentUpgrade } from './CDEquipmentUpgrade';
import { CDEquipmentStrengthen } from './CDEquipmentStrengthen';
import { CDEquipmentRune } from './CDEquipmentRune';
import { CDGem } from './CDGem';
import { CDFunction } from './CDFunction';
import { CDFunctionUnlock } from './CDFunctionUnlock';
import { CDGuideText } from './CDGuideText';
import { CDHuangXiaoxiGlobal } from './CDHuangXiaoxiGlobal';
import { CDHuangXiaoxi } from './CDHuangXiaoxi';
import { CDHuangXiaoxiDialogue } from './CDHuangXiaoxiDialogue';
import { CDHuangXiaoxiFavor } from './CDHuangXiaoxiFavor';
import { CDFavorSkill } from './CDFavorSkill';
import { CDPlantInfo } from './CDPlantInfo';
import { CDItemGlobal } from './CDItemGlobal';
import { CDItem } from './CDItem';
import { CDJump } from './CDJump';
import { CDLanguage } from './CDLanguage';
import { CDLegionShop } from './CDLegionShop';
import { CDLegionPosition } from './CDLegionPosition';
import { CDLegionCrusade } from './CDLegionCrusade';
import { CDLegionLevel } from './CDLegionLevel';
import { CDLegionDonation } from './CDLegionDonation';
import { CDLegionGlobal } from './CDLegionGlobal';
import { CDLordGlobal } from './CDLordGlobal';
import { CDUnitLv } from './CDUnitLv';
import { CDLordTraining } from './CDLordTraining';
import { CDLordPraySkill } from './CDLordPraySkill';
import { CDLordPraySkillLv } from './CDLordPraySkillLv';
import { CDLordTalent } from './CDLordTalent';
import { CDLotteryBase } from './CDLotteryBase';
import { CDLotteryList } from './CDLotteryList';
import { CDLotteryDrop } from './CDLotteryDrop';
import { CDLotteryTurntable } from './CDLotteryTurntable';
import { CDMail } from './CDMail';
import { CDMath } from './CDMath';
import { CDMissionMainLine } from './CDMissionMainLine';
import { CDMission } from './CDMission';
import { CDMissionCharge } from './CDMissionCharge';
import { CDMissionTrial } from './CDMissionTrial';
import { CDMissionRandom } from './CDMissionRandom';
import { CDMonster } from './CDMonster';
import { CDMathx } from './CDMathx';
import { CDPayGlobal } from './CDPayGlobal';
import { CDPayItem } from './CDPayItem';
import { CDPayItemFree } from './CDPayItemFree';
import { CDPayItemProduct } from './CDPayItemProduct';
import { CDPayItemCard } from './CDPayItemCard';
import { CDPaymentGlobal } from './CDPaymentGlobal';
import { CDPayment } from './CDPayment';
import { CDPetGlobal } from './CDPetGlobal';
import { CDPet } from './CDPet';
import { CDPetLv } from './CDPetLv';
import { CDPetRank } from './CDPetRank';
import { CDPetWake } from './CDPetWake';
import { CDPetWakeStage } from './CDPetWakeStage';
import { CDPetTeamUnlock } from './CDPetTeamUnlock';
import { CDPowerCalculation } from './CDPowerCalculation';
import { CDRandomEventGlobal } from './CDRandomEventGlobal';
import { CDRandomEvent } from './CDRandomEvent';
import { CDRandomEventEquipDrop } from './CDRandomEventEquipDrop';
import { CDRankGlobal } from './CDRankGlobal';
import { CDRankBossReward } from './CDRankBossReward';
import { CDRankArenaReward } from './CDRankArenaReward';
import { CDRankCrusadeReward } from './CDRankCrusadeReward';
import { CDSettingsMultil } from './CDSettingsMultil';
import { CDSettingsHead } from './CDSettingsHead';
import { CDRoleSelect } from './CDRoleSelect';
import { CDShopGlobal } from './CDShopGlobal';
import { CDShop } from './CDShop';
import { CDShopEquipmentLv } from './CDShopEquipmentLv';
import { CDShopGood } from './CDShopGood';
import { CDShopEquipmentPrice } from './CDShopEquipmentPrice';
import { CDSkillGlobal } from './CDSkillGlobal';
import { CDSkill } from './CDSkill';
import { CDSkillEffect } from './CDSkillEffect';
import { CDStageGlobal } from './CDStageGlobal';
import { CDStage } from './CDStage';
import { CDStageMainChapter } from './CDStageMainChapter';
import { CDStrength } from './CDStrength';
import { CDUnitGlobal } from './CDUnitGlobal';
import { CDUnit } from './CDUnit';
import { CDWelfareGlobal } from './CDWelfareGlobal';
import { CDWelfareSign } from './CDWelfareSign';
import { CDHandBookGlobal } from './CDHandBookGlobal';
import { CDHandBook } from './CDHandBook';
import { CDHangUpGlobal } from './CDHangUpGlobal';
import { CDHangUp } from './CDHangUp';


/**excel数据读取入口*/
export class ExcelData {

	/**已加载数*/
	public static loadedCount = -1;
	/**需载数*/
	public static loadMaxCount = 106;
	/**加载中*/
	public static inLoading = false;
	/**回调列表*/
	public static callBackList: Function[] = [];

	/**读取excel数据*/
	public static loadData(callback?: Function): void {
		if (this.inLoading) {
			if (callback) {
				this.callBackList.push(callback);
			}
			return;
		}
		if (this.loadedCount >= this.loadMaxCount) {
			if (callback) {
				callback();
			}
			return;
		}

		this.inLoading = true;
		if (callback) {
			this.callBackList.push(callback);
		}

		Loader.load("data/" + ApiUtils.ConfigVersion, (data: any) => {
			const byte = new Byte(data);
			this.loadedCount = 0;
			ITimer.frameLoop(1, this, () => {
				switch(this.loadedCount)
				{
					default:
						{
							this.inLoading = false;
							ITimer.clearAll(this);
							for (let i = 0; i < this.callBackList.length; i++) {
								this.callBackList[i]();
							}
						}
						break;
					case 0:
						CDActivityGlobal.load(byte);
						break;
					case 1:
						CDActivity.load(byte);
						break;
					case 2:
						CDArenaGlobal.load(byte);
						break;
					case 3:
						CDArenaRule.load(byte);
						break;
					case 4:
						CDArenaRobot.load(byte);
						break;
					case 5:
						CDAudio.load(byte);
						break;
					case 6:
						CDBuyTimes.load(byte);
						break;
					case 7:
						CDBuyTimeLimit.load(byte);
						break;
					case 8:
						CDDropGroup.load(byte);
						break;
					case 9:
						CDDrop.load(byte);
						break;
					case 10:
						CDDropSet.load(byte);
						break;
					case 11:
						CDDropChoose.load(byte);
						break;
					case 12:
						CDEquipmentGlobal.load(byte);
						break;
					case 13:
						CDEquipment.load(byte);
						break;
					case 14:
						CDEquipmentRMath.load(byte);
						break;
					case 15:
						CDEquipmentLevel.load(byte);
						break;
					case 16:
						CDEquipmentColor.load(byte);
						break;
					case 17:
						CDEquipmentSuit.load(byte);
						break;
					case 18:
						CDEquipmentChange.load(byte);
						break;
					case 19:
						CDEquipmentUpgrade.load(byte);
						break;
					case 20:
						CDEquipmentStrengthen.load(byte);
						break;
					case 21:
						CDEquipmentRune.load(byte);
						break;
					case 22:
						CDGem.load(byte);
						break;
					case 23:
						CDFunction.load(byte);
						break;
					case 24:
						CDFunctionUnlock.load(byte);
						break;
					case 25:
						CDGuideText.load(byte);
						break;
					case 26:
						CDHuangXiaoxiGlobal.load(byte);
						break;
					case 27:
						CDHuangXiaoxi.load(byte);
						break;
					case 28:
						CDHuangXiaoxiDialogue.load(byte);
						break;
					case 29:
						CDHuangXiaoxiFavor.load(byte);
						break;
					case 30:
						CDFavorSkill.load(byte);
						break;
					case 31:
						CDPlantInfo.load(byte);
						break;
					case 32:
						CDItemGlobal.load(byte);
						break;
					case 33:
						CDItem.load(byte);
						break;
					case 34:
						CDJump.load(byte);
						break;
					case 35:
						CDLanguage.load(byte);
						break;
					case 36:
						CDLegionShop.load(byte);
						break;
					case 37:
						CDLegionPosition.load(byte);
						break;
					case 38:
						CDLegionCrusade.load(byte);
						break;
					case 39:
						CDLegionLevel.load(byte);
						break;
					case 40:
						CDLegionDonation.load(byte);
						break;
					case 41:
						CDLegionGlobal.load(byte);
						break;
					case 42:
						CDLordGlobal.load(byte);
						break;
					case 43:
						CDUnitLv.load(byte);
						break;
					case 44:
						CDLordTraining.load(byte);
						break;
					case 45:
						CDLordPraySkill.load(byte);
						break;
					case 46:
						CDLordPraySkillLv.load(byte);
						break;
					case 47:
						CDLordTalent.load(byte);
						break;
					case 48:
						CDLotteryBase.load(byte);
						break;
					case 49:
						CDLotteryList.load(byte);
						break;
					case 50:
						CDLotteryDrop.load(byte);
						break;
					case 51:
						CDLotteryTurntable.load(byte);
						break;
					case 52:
						CDMail.load(byte);
						break;
					case 53:
						CDMath.load(byte);
						break;
					case 54:
						CDMissionMainLine.load(byte);
						break;
					case 55:
						CDMission.load(byte);
						break;
					case 56:
						CDMissionCharge.load(byte);
						break;
					case 57:
						CDMissionTrial.load(byte);
						break;
					case 58:
						CDMissionRandom.load(byte);
						break;
					case 59:
						CDMonster.load(byte);
						break;
					case 60:
						CDMathx.load(byte);
						break;
					case 61:
						CDPayGlobal.load(byte);
						break;
					case 62:
						CDPayItem.load(byte);
						break;
					case 63:
						CDPayItemFree.load(byte);
						break;
					case 64:
						CDPayItemProduct.load(byte);
						break;
					case 65:
						CDPayItemCard.load(byte);
						break;
					case 66:
						CDPaymentGlobal.load(byte);
						break;
					case 67:
						CDPayment.load(byte);
						break;
					case 68:
						CDPetGlobal.load(byte);
						break;
					case 69:
						CDPet.load(byte);
						break;
					case 70:
						CDPetLv.load(byte);
						break;
					case 71:
						CDPetRank.load(byte);
						break;
					case 72:
						CDPetWake.load(byte);
						break;
					case 73:
						CDPetWakeStage.load(byte);
						break;
					case 74:
						CDPetTeamUnlock.load(byte);
						break;
					case 75:
						CDPowerCalculation.load(byte);
						break;
					case 76:
						CDRandomEventGlobal.load(byte);
						break;
					case 77:
						CDRandomEvent.load(byte);
						break;
					case 78:
						CDRandomEventEquipDrop.load(byte);
						break;
					case 79:
						CDRankGlobal.load(byte);
						break;
					case 80:
						CDRankBossReward.load(byte);
						break;
					case 81:
						CDRankArenaReward.load(byte);
						break;
					case 82:
						CDRankCrusadeReward.load(byte);
						break;
					case 83:
						CDSettingsMultil.load(byte);
						break;
					case 84:
						CDSettingsHead.load(byte);
						break;
					case 85:
						CDRoleSelect.load(byte);
						break;
					case 86:
						CDShopGlobal.load(byte);
						break;
					case 87:
						CDShop.load(byte);
						break;
					case 88:
						CDShopEquipmentLv.load(byte);
						break;
					case 89:
						CDShopGood.load(byte);
						break;
					case 90:
						CDShopEquipmentPrice.load(byte);
						break;
					case 91:
						CDSkillGlobal.load(byte);
						break;
					case 92:
						CDSkill.load(byte);
						break;
					case 93:
						CDSkillEffect.load(byte);
						break;
					case 94:
						CDStageGlobal.load(byte);
						break;
					case 95:
						CDStage.load(byte);
						break;
					case 96:
						CDStageMainChapter.load(byte);
						break;
					case 97:
						CDStrength.load(byte);
						break;
					case 98:
						CDUnitGlobal.load(byte);
						break;
					case 99:
						CDUnit.load(byte);
						break;
					case 100:
						CDWelfareGlobal.load(byte);
						break;
					case 101:
						CDWelfareSign.load(byte);
						break;
					case 102:
						CDHandBookGlobal.load(byte);
						break;
					case 103:
						CDHandBook.load(byte);
						break;
					case 104:
						CDHangUpGlobal.load(byte);
						break;
					case 105:
						CDHangUp.load(byte);
						break;
				}
				this.loadedCount++;
			});
		});
	}
}
